﻿#include "FITKAcousticsNCTLayUp.h"


namespace Acoustics
{
    FITKAcousticsNCTAbstractLayObj::~FITKAcousticsNCTAbstractLayObj()
    {

    }

    FITKAcousticsNCTAbstractLayObj::NCTLayUpType FITKAcousticsNCTAbstractLayObj::getNCTLayUpType()
    {
        //错误值
        return None;
    }


    double FITKAcousticsNCTAbstractLayObj::getMassPerUnitArea()
    {
        //错误值
        return 0;
    }


    void FITKAcousticsNCTAbstractLayObj::setThickness(const double& t)
    {
        _thickness = t;
    }

    double FITKAcousticsNCTAbstractLayObj::getThickness() const
    {
        //获取厚度
        return _thickness;
    }

    bool FITKAcousticsNCTAbstractLayObj::copy(Core::FITKAbstractDataObject *obj)
    {
        //转换强制类型
        Acoustics::FITKAcousticsNCTAbstractLayObj* layPtr = dynamic_cast<Acoustics::FITKAcousticsNCTAbstractLayObj*>(obj);

        if(nullptr != layPtr)//判断是否为空，为空则执行父类copy函数、不为空则执行自己的copy函数
        {
            _thickness = layPtr->getThickness();
        }

        return FITKAbstractNDataObject::copy(obj);
    }

    FITKAcousticsAbsNCT::NCTType FITKAcousticsNCTLayUp::getNCTType()
    {
        //多层声学包类型
        return FITKAcousticsAbsNCT::NCTType::TreatmentLayUp;
    }

    int FITKAcousticsNCTLayUp::getLayCount()
    {
        return this->getDataCount();
    }


    double FITKAcousticsNCTLayUp::getMassPerUnitArea()
    {
        double m = 0;
        //遍历对象
        const int n = this->getDataCount();
        for (int i = 0; i< n; ++i)
        {
            FITKAcousticsNCTAbstractLayObj* lobj = this->getDataByIndex(i);
            if(lobj == nullptr) continue;
            //将全部层相加
            m += lobj->getMassPerUnitArea();
        }
        return m;
    }

    double FITKAcousticsNCTLayUp::getTotalThickness()
    {
        double t = 0;
         //遍历对象
        const int n = this->getDataCount();
        for (int i = 0; i < n; ++i)
        {
            FITKAcousticsNCTAbstractLayObj* lobj = this->getDataByIndex(i);
            if (lobj == nullptr) continue;
            //将全部层厚度相加
            t += lobj->getThickness();
        }
        return t;
    }

    double FITKAcousticsNCTLayUp::getMaxFieldAngle()
    {
        return _maxFieldAngle;
    }

    void FITKAcousticsNCTLayUp::setMaxFieldAngle(double maxfieldangle)
    {
        _maxFieldAngle = maxfieldangle;
    }

}


